Skip to content

Update createmaintenanceendpoint.*.md #1340

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ViniciusFXavier
Copy link

@ViniciusFXavier ViniciusFXavier commented Apr 17, 2025

Defer heapdump Import & Clean Up Temporary Files

  • Deferred Import: Moved require('heapdump') inside the route handler so it’s only loaded when needed.
    • Motivation:
      • Avoid V8 Patching & Memory Leaks Requiring the heapdump module patches globals in V8, which—if loaded at startup—can lead to subtle memory leaks over time. Deferring the import ensures those patches only happen during the actual dump operation.
  • Resource Cleanup: Added fs.unlink(...) to delete the generated heapdump file after it’s been sent to the client.
    • Motivation:
      • Prevent Disk Usage Buildup Each heap snapshot can be quite large. Automatically deleting the file once it’s sent avoids filling up disk space when the endpoint is called repeatedly.

Summary:
- Deferred Import: Moved const heapdump = require('heapdump') inside the route handler so it’s only loaded when needed.
- Resource Cleanup: Added fs.unlink(...) to delete the generated heapdump file after it’s been sent to the client.

Motivation:
- Avoid V8 Patching & Memory Leaks
  Requiring the heapdump module patches globals in V8, which—if loaded at startup—can lead to subtle memory leaks over time. Deferring the import ensures those patches only happen during the actual dump operation.

- Prevent Disk Usage Buildup
  Each heap snapshot can be quite large. Automatically deleting the file once it’s sent avoids filling up disk space when the endpoint is called repeatedly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant